package com.seek.web.controller;

import java.util.Iterator;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

import com.seek.core.BaseController;
import com.seek.util.file.FileConstantsUtil;
import com.seek.util.file.FileUtil;

@Controller
@RequestMapping("/fileUpload")
public class FileUploadController extends BaseController{
	
//	@RequestMapping("")
//	@ResponseBody
//	public String fileImport(HttpServletRequest request){		
//		try{
//			String destDir = "";
//			//创建一个通用的多部分解析器  
//	        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(request.getSession().getServletContext());  
//	        //判断 request 是否有文件上传,即多部分请求  
//	        if(multipartResolver.isMultipart(request)){  
//	            //转换成多部分request    
//				MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
//				// 取得request中的所有文件名
//				Iterator<String> iter = multiRequest.getFileNames();
//				while (iter.hasNext()) {
//					// 取得上传文件
//					MultipartFile file = multiRequest.getFile(iter.next());
//					String upload = FileConstantsUtil.UPLOAD_DIR_FILE;
//					upload = FileUtil.getYmdUploadDir(upload);
//					String filePath = FileUtil.upload(upload, file, FileUtil.getDestFileName(file.getOriginalFilename()));
//					destDir = FileUtil._getDestDir(filePath);
//					break;
//				}
//
//			}
//	        
//	        return returnSuccess(destDir);
//		}catch (Exception e) {
//			return returnError(e.getMessage());
//		}
//	}
	
	
}
